package com.xuecheng.auth.controller;

import com.xuecheng.ucenter.model.po.XcUser;
import com.xuecheng.ucenter.service.impl.WxAuthServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Linzkr
 * @description: TODO
 * @date 2023/2/1 16:02
 */
@Controller
public class WxLoginController {
    @Autowired
    WxAuthServiceImpl wxAuthServiceImpl;
    @RequestMapping("/wxLogin")
    public String wxLogin(@RequestParam("code") String code,@RequestParam("state")String state){
        XcUser xcUser = wxAuthServiceImpl.wxAuth(code);
        if (xcUser==null){
            return "redirect:http://www.xuecheng-plus.com/error.html";
        }else {
            String username = xcUser.getUsername();
            return "redirect:http://www.xuecheng-plus.com/sign.html?username="+ username+"&authType=wx";
        }


    }
}
